//
//  SamTabbarController.m
//  AoJiao
//
//  Created by Sam on 16/8/13.
//  Copyright © 2016年 Shawn. All rights reserved.
//

#import "SamTabbarController.h"

#import "SamNavigationController.h"

#import "MainViewController.h"


@interface SamTabbarController ()

@end

@implementation SamTabbarController

+ (void)load
{
//    UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
    NSMutableArray *array = [NSMutableArray array];
    
    [array addObject:self];
    UITabBarItem *item = [UITabBarItem appearanceWhenContainedInInstancesOfClasses:array];
//    UITabBarItem *item = [UITabBarItem appearanceWhenContainedInInstancesOfClasses:self];
    // 设置文字颜色 选中状态
    // 通过设置富文本属性(文字颜色,阴影,下划线,字体,图文混排)
    // 创建字典描述文本属性
    // 设置选中状态下颜色
    NSMutableDictionary *attributeSel = [NSMutableDictionary dictionary];
    attributeSel[NSForegroundColorAttributeName] = [UIColor colorWithHexString:@"0CD789"];
    [item setTitleTextAttributes:attributeSel forState:UIControlStateSelected];
    // 设置正常状态下字体
    NSMutableDictionary *attributeNor = [NSMutableDictionary dictionary];
    attributeNor[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    [item setTitleTextAttributes:attributeNor forState:UIControlStateNormal];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpAllChildController];
    [self setUpAllTabbarBtn];
    //设置tabbar的背景颜色
//    self.tabBar.backgroundImage = [UIImage imageWithOriginalRenderingMode:@"tabbar-light"];
    UIView *view = [[UIView alloc]initWithFrame: self.tabBar.bounds];
    view.backgroundColor = [UIColor whiteColor];
    [self.tabBar addSubview:view];
    
//    self.tabBar.tintColor = [UIColor orangeColor];    
}

-(void)setUpAllChildController{

    MainViewController *VC1 = [MainViewController new];
    SamNavigationController *NV1 = [[SamNavigationController alloc]initWithRootViewController:VC1];
    VC1.navigationItem.title = @"wechar";
    [self addChildViewController:NV1];
    
    
    MainViewController *VC2 = [MainViewController new];
    SamNavigationController *NV2 = [[SamNavigationController alloc]initWithRootViewController:VC2];
    VC2.navigationItem.title = @"联系人";
    [self addChildViewController:NV2];
    
    
    MainViewController *VC3 = [MainViewController new];
    SamNavigationController *NV3 = [[SamNavigationController alloc]initWithRootViewController:VC3];
    VC3.navigationItem.title = @"设置";
    [self addChildViewController:NV3];

}

- (void)setUpAllTabbarBtn {
    //Mall
    UIViewController *child0 = self.childViewControllers[0];
    child0.tabBarItem.image = [UIImage imageWithOriginalRenderingMode:@"客户normal"];
    child0.tabBarItem.title = @"客户";
    child0.tabBarItem.selectedImage = [UIImage imageWithOriginalRenderingMode:@"客户preesd"];
    //ShoppingCar
    UIViewController *child1 = self.childViewControllers[1];
    child1.tabBarItem.image = [UIImage imageWithOriginalRenderingMode:@"工作台normal"];
    child1.tabBarItem.selectedImage = [UIImage imageWithOriginalRenderingMode:@"工作台preesd"];
    child1.tabBarItem.title = @"工作台";
    //Me
    UIViewController *child2 = self.childViewControllers[2];
    child2.tabBarItem.image = [UIImage imageWithOriginalRenderingMode:@"我normal"];
    child2.tabBarItem.selectedImage = [UIImage imageWithOriginalRenderingMode:@"我preesd"];
    child2.tabBarItem.title = @"我";
    //我

}

@end
